package com.example.mobile2021606144ywr0407homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity3 extends AppCompatActivity {

    private TextView tvMainTitle2;
    private TextView tvMain21;
    private TextView tvMain22;
    private TextView tvMain23;
    private EditText editMain21;
    private TextView tvMain24;
    private EditText editMain22;
    private TextView tvMain2;
    private EditText editMain23;
    private Button btnMain2End;
    private TextView txt1;
    int Max = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        initView();
        btnMain2End.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = editMain21.getText().toString();
                String string1 = editMain22.getText().toString();
                String string2 = editMain23.getText().toString();
                int num1=Integer.valueOf(string).intValue();
                int num2=Integer.valueOf(string1).intValue();
                int num3=Integer.valueOf(string2).intValue();
                if (num1 > num2 ){
                    Max = num1;
                }else {
                    Max = num2;
                }
                if (num2 > num3){
                    Max = num2;
                }else {
                    Max = num3;
                }
                if (num1 > num3){
                    Max = num1;
                }else {
                    Max = num3;
                }
                string=String.valueOf(Max);
                txt1.setText(string);
            }
        });
    }

    private void initView() {
        tvMainTitle2 = (TextView) findViewById(R.id.tv_main_title2);
        tvMain21 = (TextView) findViewById(R.id.tv_main2_1);
        tvMain22 = (TextView) findViewById(R.id.tv_main2_2);
        tvMain23 = (TextView) findViewById(R.id.tv_main2_3);
        editMain21 = (EditText) findViewById(R.id.edit_main2_1);
        tvMain24 = (TextView) findViewById(R.id.tv_main2_4);
        editMain22 = (EditText) findViewById(R.id.edit_main2_2);
        tvMain2 = (TextView) findViewById(R.id.tv_main2_);
        editMain23 = (EditText) findViewById(R.id.edit_main2_3);
        btnMain2End = (Button) findViewById(R.id.btn_main2_end);
        txt1 = (TextView) findViewById(R.id.txt1);
    }
}